package Text10;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static int N = 12010;
    public static int[] f = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<good> goods = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            int v = in.nextInt();
            int w = in.nextInt();
            int s = in.nextInt();
            for (int j = 1; j <= s; j *= 2) {
                s -= j;
                goods.add(new good(j * v, j * w));
            }
            if (s > 0) {
                goods.add(new good(s * v, s * w));
            }
        }
        for (good g : goods) {
            for (int i = m; i >= g.v; i--) {
                f[i] = Math.max(f[i], f[i - g.v] + g.w);
            }
        }
        System.out.println(f[m]);
    }
}

class good {
    int v, w;

    public good(int v, int w) {
        this.v = v;
        this.w = w;
    }
}
